Subscribe Us

Responsive Advertisement

Advertisement

Codeforces Round #761 (Div. 2) problem A solution in cpp

 

Codeforces Round #761 (Div. 2) problem A  solution in cpp

by ujjal roy


#include<bits/stdc++.h>

using namespace std;

main()

{


    int t,i,j;

    cin>>t;

    while(t--)

    {

        map<char , int> m;

        char ch;

        string s,t,ans;

        cin>>s>>t;

        for(i=0;i<s.size();i++) m[s[i]]++;

        if(t=="abc"&&m['a']!=0&&m['b']!=0&&m['c']!=0)

        {

            for(i=0;i<m['a'];i++) ans+='a';

            for(i=0;i<m['c'];i++) ans+='c';

            for(i=0;i<m['b'];i++) ans+='b';

            for(ch='d';ch<='z';ch++)

            {

                  for(i=0;i<m[ch];i++) ans+=ch;

            }

            cout<<ans<<endl;

        }

        else

        {

            sort(s.begin(),s.end());

            cout<<s<<endl;

        }


    }

return 0;

}


Post a Comment

0 Comments